from flask import Flask, render_template
import pandas as pd

df1 = pd.read_csv("data/中国疫情.csv", index_col=0)
df2 = pd.read_csv("data/北京每个小时空气质量.csv", index_col=0)
df3 = pd.read_csv("data/房源数量占比.csv")

sort_fy = df3.sort_values('房源数量分布占比', ascending=False).reset_index(drop=True)
data = sort_fy.iloc[:10]
area_list = data['省份'].tolist()
value_list = data['房源数量分布占比'].tolist()

sort_yq = df1.sort_values('累计', ascending=False).reset_index(drop=True)
sort_yq = sort_yq[:10]
add = sort_yq['新增'].tolist()
now = sort_yq['现有'].tolist()
all = sort_yq['累计'].tolist()
areas = sort_yq['地区'].tolist()
well = sort_yq['治愈'].tolist()
died = sort_yq['死亡'].tolist()

app = Flask(__name__)


@app.route("/")
def index():
    # 渲染模板的同时将数据传输进去
    return render_template("饼图.html", area=area_list, value=value_list, add=add, now=now, all=all, areas=areas,
                           well=well, died=died)


if __name__ == '__main__':
    app.run(debug=True)
